#include <iostream>
#include <string>
using namespace std;

int main()
{
    string s;
    int n;
    cin >> s >> n;

    string res = "";
    int ans = -1;

    for (int i = 0; i < s.size(); ++i)
    {
        string tmp = s.substr(i, min(n, (int)s.size() - i));
        int cnt = 0;
        for (char c : tmp)
            if (c == 'G' || c == 'C')
                cnt++;

        if (cnt > ans)
        {
            res = tmp;
            ans = cnt;
        }
    }

    cout << res << endl;
    return 0;
}
